<%@ page import="java.util.*" %>

<jsp:useBean id="cart" scope="session" class="sklep.Koszyk" />
<html>
	<head>
		<title>Shopping Cart</title>
	</head>
	<body>
		<div align="center">
			<% int itemsBought = cart.checkBuy(request); %>
			<table border="1">
			<caption><b>Shopping Cart Contents</b></caption>
			<tr>
				<th>Product</th>
				<th>Price</th>
				<th>Quantity</th>
			</tr>
			<%
			Enumeration e = cart.getEnumeration();
			String[] tmpItem;
			
			while (e.hasMoreElements()) 
			{
				tmpItem = (String[])e.nextElement();
		 	%>
			<tr>
				<td><%=tmpItem[1] %></td>
				<td align="center">$<%=tmpItem[2] %></td>
				<td align="center"><%=tmpItem[3] %></td>
			</tr>
			<%
			}
			%> 
			</table>
			<p>Total cost: <%=cart.getCost() %>$</p>
			<% if(cart.getNumOfItems() != 0 )
			{
			%>
			<form action="koszyk.jsp" method="post">
				<input type="submit" name="Buy" value="Buy">
			</form>
			<%
			} 
			else if(itemsBought > 0)
			{
				out.write("<p>Zakupiono: " + itemsBought + " rzeczy.</p>");
			}
			%>
		</div>
		<a href="main.jsp">Back to Catalog</a>
	</body>
</html>

